class XP_Utils_Split_String:
  def __init__(self):
        pass
    
  @classmethod
  def INPUT_TYPES(cls):
      return {"required":
            {   
              "string": ('STRING', {"forceInput": True}),
              "delimiter": ('STRING', {"default": ","})
            }
          }

  RETURN_TYPES = ("LIST",)
  RETURN_NAMES = ("list",)
  OUTPUT_NODE = True
  FUNCTION = "sample"
  CATEGORY = "XP_Utils"

  def sample(self, string, delimiter=","):
      """
      Splits a string into a list of substrings based on whitespace.
      """
      # Split the string into a list of substrings
      # using the specified delimiter
      # If the delimiter is empty, use whitespace as the default delimiter
      if not delimiter:
          delimiter = " "
      # Split the string using the specified delimiter
      # Use the split method to split the string into substrings
      # If the delimiter is not found, the entire string is returned as a single substring
      # If the delimiter is empty, split by whitespace
      # The split method returns a list of substrings
      if delimiter != "":
          substrings = string.split(delimiter)
      else:
          substrings = string.split(" ")
      
      # Return the list of substrings
      return (substrings,)